package com.example.xyh.Controller;

import com.example.xyh.dto.LineItemDto;
import com.example.xyh.service.LineItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping
@Tag(name = "Item", description = "ItemController")
public class LineItemController {
    @Resource
    LineItemService lineItemService;

    @Autowired
    public LineItemController(LineItemService lineItemService) {
        this.lineItemService = lineItemService;
    }

    @PostMapping("/BusinessItemList")
    public List<LineItemDto> BusinessItemList(Integer business_id) {
        return lineItemService.getBusinessItemList(business_id);
    }

    @PostMapping("/AddItem")
    public LineItemDto addItem(Integer business_id, String item_name, Double item_price) {
        return lineItemService.addItem(business_id, item_name, item_price);
    }

}
